﻿using System;
using System.Device.Location;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SydEnergiPrototype.DataRepositoryServiceRef;
using SydEnergiPrototype.Model;

namespace SydEnergiPrototype.Logic
{
    public class ManualFactory : IFactory
    {
        public static object CreateFromType(Type t)
        {
            if (t == typeof(Entry))
                return new Entry(new History(), new Address());
            if (t == typeof(EntryDto))
                return new EntryDto();
            if (t == typeof(IAddress) || t == typeof(Address))
                return new Address();
            if (t == typeof(AddressDto))
                return new AddressDto();
            if (t == typeof(HistoryEntry))
                return new HistoryEntry();
            if (t == typeof(HistoryEntryDto))
                return new HistoryEntryDto();
            if (t == typeof(Cabinet) || t == typeof(ICabinet))
                return new Cabinet();
            if (t == typeof(CabinetDto))
                return new CabinetDto();

            throw new Exception("Cannot instantiate from referred type: " + t);
        }

        private HistoryEntryDto CreateHistoryEntryDto()
        {
            return new HistoryEntryDto();
        }

        private HistoryEntry CreateHistoryEntry()
        {
            return new HistoryEntry();
        }

        private EntryDto CreateEntryDto()
        {
            return new EntryDto();
        }

        public IEntry CreateEntry()
        {
            return new Entry(CreateHistory(), CreateAddress());
        }

        public History CreateHistory()
        {
            return new History();
        }

        public IAddress CreateAddress()
        {
            return new Address();
        }

        public SerializableEntry CreateSerializableEntry()
        {
            return new SerializableEntry();
        }

        public IDataRepositoryService CreateDataRepositoryClient()
        {
            return new DataRepositoryServiceClient();
        }

        public AddressDto CreateAddressDto()
        {
            return new AddressDto();
        }

        public CabinetDto CreateCabinetDto()
        {
            return new CabinetDto();
        }

        public ICabinet CreateCabinet(string id, IAddress address, GeoCoordinate position)
        {
            return new Cabinet(id, address, position);
        }
    }
}
